package main

import (
	"flag"
	"fmt"
	"github.com/astaxie/beego"
	"github.com/phachon/mm-wiki/install/storage"
	"log"
	"os"
	"path/filepath"
)

var (
	port = flag.String("port", "8091", "please input listen port")
)

func main() {
	flag.Parse()

	lockPath := filepath.Join(storage.RootDir, "./install.lock")
	fmt.Printf("lockPath is %s \n", lockPath)
	_, err := os.Stat(lockPath)

	if err == nil || !os.IsNotExist(err) {
		log.Println("MM-Wiki already installed!")
		os.Exit(1)
	}

	beego.BConfig.RunMode = "prod"
	beego.Run(":" + *port)
}
